import SimpleITK as sitk
outTx=sitk.ReadTransform('3reg9.mat')
print(outTx)

now=9
moving=sitk.ReadImage('Masked/'+str(3)+'masked.nii',sitk.sitkFloat32)
fixed=sitk.ReadImage('Masked/'+str(now)+'masked.nii',sitk.sitkFloat32)

output=sitk.Resample(moving,outTx,sitk.sitkLinear,800,sitk.sitkInt16)
sitk.WriteImage(output,'3transf4med.nii')
exit(0)

resampler = sitk.ResampleImageFilter()
# resampler.SetReferenceImage(fixed)
resampler.SetInterpolator(sitk.sitkLinear)
resampler.SetDefaultPixelValue(800)
resampler.SetTransform(outTx)
resampler.SetOutputPixelType(sitk.sitkInt16)

out = resampler.Execute(moving)
sitk.WriteImage(out,'9transf4medWithoutRef.nii')

